home *** CD-ROM | disk | FTP | other *** search
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
- <html>
- <head>
- <title>Gestione foto di Mario Rossi</title>
- </head>
-
- <body>
-
- <h1>Inserimento nuova foto</h1>
-
- <%
-
- Const adOpenForwardOnly = 0
- Const adLockReadOnly = 1
-
- Dim contatore
- Dim sql1,sql2
- Dim conn, rs
- Dim i,j
-
- Dim strNome, strTitolo, strData, strLuogo, strProvincia, strStato
-
- strNome = request.Form("nome")
- strTitolo = request.Form("titolo")
- strData = request.Form("datagg") & "/" & request.Form("datamm") & "/" & request.Form("datayyyy")
- strLuogo = request.Form("luogo")
- strProvincia = request.Form("provincia")
- strStato = request.Form("stato")
-
- Set conn = Server.CreateObject("ADODB.Connection")
- conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/foto2.mdb")
-
- sql = "SELECT count(*) AS totale FROM Foto WHERE nome = '" & request.Form("nome") & "'"
-
- Set rs = Server.CreateObject("ADODB.RecordSet")
- rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly
-
- 'Qualche controllo
-
- If rs("totale") > 0 Then
- 'Esiste una foto giα inserita con lo stesso ID
- response.write "Questo nome di foto esiste giα nella tabella, devi sceglierne un altro<br>"
- response.write "Ritorna alla<a href=""inseriscifoto.asp"">pagina di inserimento</a>"
- response.end
- End If
-
- If Not IsDate(strData) Then
- 'Data in formato non valido
- response.write "La data inserita (" & strData & ") non Φ valida<br>"
- response.write "Ritorna alla<a href=""inseriscifoto.asp"">pagina di inserimento</a>"
- response.end
- End If
-
- 'Rinforzo l'accento per evitare problemi in inserimento
- strNome = replace(strNome,"'","''")
- strTitolo = replace(strTitolo,"'","''")
- strLuogo = replace(strLuogo,"'","''")
-
- sql = "INSERT INTO Foto ( Nome, Titolo, Data, Luogo, IdProvincia, IdStato ) VALUES (" & _
- "'" & strNome & "', " & _
- "'" & strTitolo & "', " & _
- "'" & strData & "', " & _
- "'" & strLuogo & "', " & _
- "'" & strProvincia & "', " & _
- "'" & strStato & "' " & _
- ")"
-
- on error resume next
-
- conn.Execute sql
-
- If ConnError(conn) > 0 Then
- response.write "Si Φ verificato un problema con l'inserimento dei dati.<br>"
- response.write "Ritorna alla <a href=""inseriscifoto.asp"">pagina di inserimento</a>"
- Else
- response.write "I dati della foto sono stati inseriti correttamente<br>"
- response.write "Ritorna all'<a href=""gestione.asp"">elenco delle foto</a>"
- End If
-
- on error goto 0
-
- set rs = nothing
- conn.close
- set conn = nothing
-
- Function ConnError(conn)
-
- Dim i
- i = 0
-
- For Each errorObject In conn.Errors
- i = i + 1
- Response.Write "ERRORE: " & errorObject.Description & "<br><br>"
- Next
-
- ConnError = i
-
- End Function
-
- %>
-
-